/**
 * 
 */
package springbootstudy.jdbc.repository;

import javax.annotation.Resource;

import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;

import springbootstudy.hibernate.Person;

/**
 * @author Administrator
 *
 */
@Repository
public class PersonDaoImpl implements PersonDao {

	@Resource
	private JdbcTemplate jdbcTemplate;

	@Override
	public Person selectOne(Long id) {
		String sql = "select * from Person where id=?";
		RowMapper<Person> rowMapper=new BeanPropertyRowMapper<Person>(Person.class);
		Person p=jdbcTemplate.queryForObject(sql, new Object[]{id}, rowMapper);
		return p;
	}

}
